package cn.iune;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;

import cn.iune.system.config.ApplicationNode;

/*
 * APPCENTER
 */

//@ServletComponentScan("cn.iune.web.security.filters")//加载注解过滤器
//@ComponentScan(basePackages = {"cn.iune"})
//@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.CUSTOM, classes = {ShiroFilterFactoryBean.class}))
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class })
//@SpringBootApplication
public class U2devAppcenterApplication {

	public static void main(String[] args) {
		ApplicationContext ctx = SpringApplication.run(U2devAppcenterApplication.class, args);
		System.out.println("ctx.getApplicationName()-->>"+ctx.getApplicationName());
		String displayName = ctx.getDisplayName();
		System.out.println("ctx.getDisplayName()-->>"+displayName);
		System.out.println("ctx.getId()-->>"+ctx.getId());
		System.out.println("ctx.getBeanDefinitionCount()-->>"+ctx.getBeanDefinitionCount());

//		String[] beanNames = ctx.getBeanDefinitionNames();
//		System.out.println("==============================================");
//		for(int i=0;i<beanNames.length;i++) {
//			System.out.println(beanNames[i]);
//		}
//		System.out.println("==============================================");
	}
	
	/**
	 * 主页控制器
	 */
	@Controller
	@RequestMapping(value = "/")
	public class IndexController {
		
	    @RequestMapping(value = "/")
	    public String index(){
	        System.out.println("/index");
	        return "index";
	    }
		
//	    @RequestMapping(value = "/login")
//	    public String login(){
//	        System.out.println("/login");
//	        return "loginone";
//	    }
	    
	    @RequestMapping(value = "/admin", method=RequestMethod.GET)
	    public String admin(){
	        System.out.println("/admin");
	        return "admin/index";
	    }

	    
	    
	}
	
	@RestController
	@RequestMapping(value = "/api")
	static class TestController {
		
		@RequestMapping(value = "/hello")
	    public String index(){
	        System.out.println("/hello api");
	        ApplicationNode.test();
	        System.out.println("/hello api ok");
	        return "this is api test!";
	    }
        
    }
}
